package com.ruoyi.basebill.controller;

import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.basebill.domain.WfzXczbsb;
import com.ruoyi.basebill.service.IWfzXczbsbService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 薪酬总表-当月社保数据Controller
 * 
 * @author lxl
 * @date 2023-01-12
 */
@RestController
@RequestMapping("/basebill/xczbsb")
public class WfzXczbsbController extends BaseController
{
    @Autowired
    private IWfzXczbsbService wfzXczbsbService;

    /**
     * 查询薪酬总表-当月社保数据列表
     */
    @PreAuthorize("@ss.hasPermi('basebill:xczbsb:list')")
    @GetMapping("/list")
    public TableDataInfo list(WfzXczbsb wfzXczbsb)
    {
        startPage();
        List<WfzXczbsb> list = wfzXczbsbService.selectWfzXczbsbList(wfzXczbsb);
        return getDataTable(list);
    }

    /**
     * 导出薪酬总表-当月社保数据列表
     */
    @PreAuthorize("@ss.hasPermi('basebill:xczbsb:export')")
    @Log(title = "薪酬总表-当月社保数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WfzXczbsb wfzXczbsb)
    {
        List<WfzXczbsb> list = wfzXczbsbService.selectWfzXczbsbList(wfzXczbsb);
        ExcelUtil<WfzXczbsb> util = new ExcelUtil<WfzXczbsb>(WfzXczbsb.class);
        util.exportExcel(response, list, "薪酬总表-当月社保数据数据");
    }

    /**
     * 获取薪酬总表-当月社保数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('basebill:xczbsb:query')")
    @GetMapping(value = "/{fid}")
    public AjaxResult getInfo(@PathVariable("fid") Long fid)
    {
        return success(wfzXczbsbService.selectWfzXczbsbByFid(fid));
    }

    /**
     * 新增薪酬总表-当月社保数据
     */
    @PreAuthorize("@ss.hasPermi('basebill:xczbsb:add')")
    @Log(title = "薪酬总表-当月社保数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WfzXczbsb wfzXczbsb)
    {
        wfzXczbsb.setFcreator(getUsername());
        wfzXczbsb.setFlastupdateuser(getUsername());
        return toAjax(wfzXczbsbService.insertWfzXczbsb(wfzXczbsb));
    }

    /**
     * 修改薪酬总表-当月社保数据
     */
    @PreAuthorize("@ss.hasPermi('basebill:xczbsb:edit')")
    @Log(title = "薪酬总表-当月社保数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WfzXczbsb wfzXczbsb)
    {
        wfzXczbsb.setFlastupdateuser(getUsername());
        wfzXczbsb.setFlastupdatetime(new Date());
        return toAjax(wfzXczbsbService.updateWfzXczbsb(wfzXczbsb));
    }

    /**
     * 删除薪酬总表-当月社保数据
     */
    @PreAuthorize("@ss.hasPermi('basebill:xczbsb:remove')")
    @Log(title = "薪酬总表-当月社保数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{fids}")
    public AjaxResult remove(@PathVariable Long[] fids)
    {
        return toAjax(wfzXczbsbService.deleteWfzXczbsbByFids(fids));
    }

    /**
     * 批量审核薪酬总表
     */
    @PreAuthorize("@ss.hasPermi('basebill:xczbsb:remove')")
    @Log(title = "薪酬总表", businessType = BusinessType.UPDATE)
    @PutMapping("/audit/{fids}")
    public AjaxResult audit(@PathVariable Long[] fids)
    {
        return toAjax(wfzXczbsbService.auditWfzXczbsbByFids(fids));
    }

    /**
     * 批量反审核薪酬总表
     */
    @PreAuthorize("@ss.hasPermi('basebill:xczbsb:remove')")
    @Log(title = "薪酬总表", businessType = BusinessType.UPDATE)
    @PutMapping("/deAudit/{fids}")
    public AjaxResult deAudit(@PathVariable Long[] fids)
    {
        return toAjax(wfzXczbsbService.deAuditWfzXczbsbByFids(fids));
    }

    /**
     * 批量废弃薪酬总表
     */
    @PreAuthorize("@ss.hasPermi('basebill:xczbsb:remove')")
    @Log(title = "薪酬总表", businessType = BusinessType.UPDATE)
    @PutMapping("/disuse/{fids}")
    public AjaxResult disuse(@PathVariable Long[] fids)
    {
        return toAjax(wfzXczbsbService.disuseWfzXczbsbByFids(fids));
    }

    /**
     * 修改薪酬总表单据状态
     */

    @Log(title = "薪酬总-计提工资福利", businessType = BusinessType.UPDATE)
    @PutMapping("/operation/{fids}/{fstate}")
    public AjaxResult operation(@PathVariable Long[] fids,@PathVariable String fstate) {

        return  toAjax(wfzXczbsbService.operation(fids,fstate));
    }
}
